﻿using DG.Tweening;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
/// <summary>
/// 开启和关闭时，缩小和放大的动画
/// </summary>
public class ScaleAnimation : IEffect {
    public float maxScale = 1;
    public float minScale = 0;
    public float due = 0.5f;
    private Tween mtween;
    protected override void OnEnable()
    {
        transform.DOScale(maxScale, due);
    }
    protected override void OnDisable()
    {
       mtween= transform.DOScale(minScale, due).OnComplete(
            ()=> { gameObject.SetActive(false); });
    }

    public override void Enable()
    {
        if(mtween!=null)
        if (mtween.IsPlaying())
        {
            mtween.Kill();
        }
        gameObject.SetActive(true);
    }

    public override void Disable()
    {
        OnDisable();

    }

   
}
